package com.chen.user.controller;


import com.chen.user.common.Result;
import com.chen.user.entity.UserLogin;
import com.chen.user.request.UserRequest;
import com.chen.user.response.UserResponse;
import com.chen.user.service.UserPersonalService;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserPersonalController {

    @Autowired
    private UserPersonalService userPersonalService;

//    @GetMapping("/getUser")
//    public Result<UserResponse> getUser(@RequestParam(defaultValue = "1") Integer id){
//      UserResponse user=  userPersonalService.getUser(id);
//      return Result.success(user);
//    }

    @PutMapping("/updateUser")
    public Result updateUser(@RequestBody UserRequest userRequest){
       Result result= userPersonalService.updateUser(userRequest);
       return result;
    }


    /**
     * 注册
     */

    @PostMapping("/register")
    public Result register(@RequestBody UserLogin user){

       Result result= userPersonalService.register(user);
       return result;
    }

    /**
     * 登录接口
     */
    @PostMapping("/login")
    public Result login(@RequestBody UserLogin user){
       Result result= userPersonalService.login(user);
       return result;
    }



}
